const Mock = require('mockjs')
const { deepClone } = require('../utils')
const { asyncRoutes, constantRoutes } = require('./routes.js')

const routes = deepClone([...constantRoutes, ...asyncRoutes])
/**
 * @author: 刘凯利
 * @day: 2022.2.11
 */
const roles = [
  {
    id: 2,
    name: '用户权限',
    icon: 'el-icon-s-help',
    page_key: '/permissions',
    operate_key: '不知道是啥',
    api_key: '不知道是啥',
    pid: '1-2',
    level: '层级',
    type: 1,
    is_leaf: 0,
    new_page: '点击菜单是否在新页面打开',
    data_row: '不知道是啥',
    data_column: '不知道是啥',
    children: [
      {
        id: 3,
        name: '用户及部门',
        icon: 'el-icon-s-check',
        page_key: '/permissions/menu/department',
        operate_key: '不知道是啥',
        api_key: '不知道是啥',
        pid: '1-2-1',
        level: '层级',
        type: 1,
        is_leaf: 1,
        new_page: '点击菜单是否在新页面打开',
        data_row: '不知道是啥',
        data_column: '不知道是啥',
        children: [
          {
            id: 4,
            name: '个人详情',
            icon: '',
            page_key: '/permissions/menu/department/userinfo',
            operate_key: '不知道是啥',
            api_key: '不知道是啥',
            pid: '1-2-1',
            level: '层级',
            type: 2,
            is_leaf: 1,
            new_page: '点击菜单是否在新页面打开',
            data_row: '不知道是啥',
            data_column: '不知道是啥'
          },
          {
            id: 5,
            name: '用户详情',
            icon: '',
            page_key: '/permissions/menu/department/othersinfo',
            operate_key: '不知道是啥',
            api_key: '不知道是啥',
            pid: '1-2-1',
            level: '层级',
            type: 2,
            is_leaf: 1,
            new_page: '点击菜单是否在新页面打开',
            data_row: '不知道是啥',
            data_column: '不知道是啥'
          },
          {
            id: 5,
            name: '部门分配用户',
            icon: '',
            page_key: '/permissions/menu/department/departmentadd',
            operate_key: '不知道是啥',
            api_key: '不知道是啥',
            pid: '1-2-1',
            level: '层级',
            type: 2,
            is_leaf: 1,
            new_page: '点击菜单是否在新页面打开',
            data_row: '不知道是啥',
            data_column: '不知道是啥'
          }
        ]
      },
      {
        id: 6,
        name: '角色及权限',
        icon: 'clipboard',
        page_key: '/permissions/menu/position',
        operate_key: '不知道是啥',
        api_key: '不知道是啥',
        pid: '1-2-2',
        level: '层级',
        type: 1,
        is_leaf: 1,
        new_page: '点击菜单是否在新页面打开',
        data_row: '不知道是啥',
        data_column: '不知道是啥',
        children: [
          {
            id: 5,
            name: '角色分配用户',
            icon: '',
            page_key: '/permissions/menu/position/roleadd',
            operate_key: '不知道是啥',
            api_key: '不知道是啥',
            pid: '1-2-1',
            level: '层级',
            type: 2,
            is_leaf: 1,
            new_page: '点击菜单是否在新页面打开',
            data_row: '不知道是啥',
            data_column: '不知道是啥'
          }
        ]
      }

    ]
  },

  {
    permission_list: ['sys:123:123']
  }
]

module.exports = [
  // mock get all routes form server
  {
    url: '/vue-element-admin/routes',
    type: 'get',
    response: _ => {
      return {
        code: 20000,
        data: routes
      }
    }
  },

  // mock get all roles form server
  {
    url: '/vue-element-admin/roles',
    type: 'get',
    response: _ => {
      return {
        code: 20000,
        data: roles
      }
    }
  },

  // add role
  {
    url: '/vue-element-admin/role',
    type: 'post',
    response: {
      code: 20000,
      data: {
        key: Mock.mock('@integer(300, 5000)')
      }
    }
  },

  // update role
  {
    url: '/vue-element-admin/role/[A-Za-z0-9]',
    type: 'put',
    response: {
      code: 20000,
      data: {
        status: 'success'
      }
    }
  },

  // delete role
  {
    url: '/vue-element-admin/role/[A-Za-z0-9]',
    type: 'delete',
    response: {
      code: 20000,
      data: {
        status: 'success'
      }
    }
  }
]
